/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gitee.huangjianbo.supos.openapi.core.tools;

import java.util.UUID;

/**
 * ID生成工具类
 * 
 * @author tomcat
 * @version 1.0
 */
public final class IdUtils {

    /**
     * 获得纳秒
     *
     * @return 纳秒ID, 19位, 例如: 1529841925999999999
     */
    public static long getNanoId() {
        return System.nanoTime();
    }

    /**
     * 获得毫秒
     *
     * @return 毫秒ID，13位, 例如: 1529841925999
     */
    public static long getMillsId() {
        return System.currentTimeMillis();
    }

    /**
     * 获得UUID
     *
     * @param lowerOrElseUpperCase 是否转小写
     * @param removeStrokeLine     是否移除中划线
     * @return UUID
     */
    public static String getUUID(boolean lowerOrElseUpperCase, boolean removeStrokeLine) {
        String id = UUID.randomUUID().toString();
        if (lowerOrElseUpperCase) {
            id = id.toLowerCase();
        }
        if (removeStrokeLine) {
            id = id.replace("-", "");
        }
        return id;
    }
}
